package logic

import (
	"context"
	"srv/renrenzu"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type SyncGoodsEsOneLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSyncGoodsEsOneLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SyncGoodsEsOneLogic {
	return &SyncGoodsEsOneLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *SyncGoodsEsOneLogic) SyncGoodsEsOne(req *types.SyncGoodsEsOneRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	one, err := l.svcCtx.RenRenZu.SyncGoodsEsOne(l.ctx, &renrenzu.SyncGoodsEsOneRequest{KeyName: req.Keyname})

	if err != nil {
		return &types.Response{
			Msg:  "搜索失败",
			Code: 500,
			Data: nil,
		}, nil
	}
	return &types.Response{
		Msg:  "搜索成功",
		Code: 200,
		Data: map[string]interface{}{
			"list": one,
		},
	}, nil
}
